<template>
  <!-- 显示隐私政策授权弹窗 -->
  <u-popup
    v-model="showPrivacyPolicy"
    mode="bottom"
    :mask-close-able="false"
    height="550rpx"
  >
    <view class="popupPrivacyPolicy">
      <text class="privacy_title">服务协议与隐私政策</text>
      <view class="privacy_content"
        >感谢您选择一览职业小程序，依据最新法律要求，使用我们的产品前，请仔细阅读并同意<text
          style="color: #f75a3e"
          @click="clickSevice"
          >《服务协议》</text
        >和<text style="color: #f75a3e" @click="clickPrivacy">《隐私政策》</text
        >，以便我们向您提供更优质的服务！我们承诺将尽全力保护您的个人信息及合法权益，再次感谢您的信任！
      </view>
      <view class="bottom_btn">
        <view class="bottom_btn_refuse" @click="handleRefuse"> 拒绝 </view>
        <view class="bottom_btn_agree" @click="handleAgree"> 同意并继续 </view>
      </view>
    </view>
  </u-popup>
</template>

<script>
export default {
  data() {
    return {
      showPrivacyPolicy: false,
    };
  },
  created() {
    // 获取用户授权状态值
    const authStatus = uni.getStorageSync("privacyAuthStatus");
    console.log("authStatus", authStatus);
    // 判断是否已经授权
    if (!authStatus) {
      // 显示隐私政策授权弹窗
      this.showPrivacyPolicy = true;
    } else {
      this.showPrivacyPolicy = false;
    }
  },
  methods: {
    handleRefuse() {
      // 用户拒绝授权
      uni.setStorageSync("privacyAuthStatus", false);
      uni.showToast({
        icon: "none",
        title: "非常抱歉无法为您继续提供服务，请手动关闭小程序",
      });
      return;
    },
    handleAgree() {
      // 用户同意授权
      uni.setStorageSync("privacyAuthStatus", true);
      this.showPrivacyPolicy = false;
      this.$emit("clickBack", {
        privacyAuthStatus: true,
      });
    },
    //服务协议
    clickSevice() {
      uni.navigateTo({
        url: `/pagesSub/public/web/BasewebView?url=${encodeURIComponent(
          "https://m5.yl1001.com/marketing/about/agreement.html"
        )}&title=用户服务协议`,
      });
    },
    //隐私政策
    clickPrivacy() {
      uni.navigateTo({
        url: `/pagesSub/public/web/BasewebView?url=${encodeURIComponent(
          "https://m5.yl1001.com/marketing/about/security.html"
        )}`,
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.popupPrivacyPolicy {
  display: flex;
  flex-direction: column;
  padding-left: 50rpx;
  padding-right: 50rpx;
}
.privacy_title {
  font-size: 32rpx;
  color: #222222;
  font-weight: 500;
  margin-top: 40rpx;
  text-align: center;
}
.privacy_content {
  margin-top: 40rpx;
}
.bottom_btn {
  display: flex;
  justify-content: row;
  padding-top: 80rpx;
}
.bottom_btn_refuse {
  flex: 1;
  width: 40%;
  height: 88rpx;
  color: #ffffff;
  text-align: center;
  background: #aaaaaa;
  border-radius: 44rpx;
  line-height: 88rpx;
}
.bottom_btn_agree {
  flex: 2;
  width: 40%;
  height: 88rpx;
  color: #ffffff;
  text-align: center;
  margin-left: 20rpx;
  background: #f75a3e;
  border-radius: 44rpx;
  line-height: 88rpx;
}
</style>
